<template>
  <div class='comments-list'>
    <div class='title'
         v-if='comments.length'>
      评论
    </div>
    <div class='comments'
         v-for='comment in comments'
         :key='comment.id'
         @click='handleClick(comment)'>
      <div class='user'>
        <img :src="comment.user_info.image"
             class='avatar'
             mode='aspectFit'>
        <span>{{comment.user_info.nickName}}</span>
      </div>
      <div class='right'>
        {{comment.location}}
        --
        {{comment.phone}}
      </div>
      <div class='content'>
        <p>{{comment.comment}}</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['comments', 'type'],
  methods: {
    handleClick (item) {
      if (this.type === 'user') {
        wx.navigateTo({
          url: '/pages/detail/main?id=' + item.bookid
        })
      }
    }
  }
}
</script>

<style scoped lang='scss'>
.comments-list {
  background: #eee;
  font-size: 14px;
  .title {
    font-size: 18px;
    line-height: 40px;
    padding-left: 5px;
  }
  .comments {
    background: white;
    padding: 5px 10px;
    margin-bottom: 5px;
    .user {
      display: inline-block;

      .avatar {
        width: 20px;
        height: 20px;
        border-radius: 50%;
        vertical-align: middle;
        margin-right: 5px;
      }
    }
    .right {
      float: right;
    }
    .content {
      margin: 10px 0;
    }
  }
}
</style>